Ext.onReady(function(){
		var d = new Date();

		var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
	
		var fileAttachment = Ext.create('component.file.attachment',{
	        objectId: '',
	        imageType: "6",
	        contextPath:contextPath,
	        colspan:2
	    });
		
	   var fromPanelInfo = Ext.create('Ext.form.FormPanel',{
		   renderTo:Ext.getBody(),
		   titleAlign:'center',
	       collapsible: false,
	       autoScroll:false,
	       defaultType : 'textfield',
			defaults : {
				anchor : '95%',
				border: true
			},
			fieldDefaults : {
				flex : 1
			},
	       title:'退认筹审批审批单',
		   items:[{
				xtype : "panel",
				layout : "hbox",
				items : [ {
					   xtype:'displayfield',
			    	   fieldLabel:'认筹编号',
			    	   name:'depositCode'
			    	   
				}, {
					 xtype:'displayfield',
			    	 fieldLabel:'认筹日期',
			    	 name:'didTime',
		                renderer:function(val){
		                	if(val==null||val==""){
		                		return "";
		                	}
		                	return Ext.Date.format(new Date(val),'Y-m-d');
		                }
				}]
			},{
				xtype : "panel",
				layout : "hbox",
				items : [ {
					 xtype:'displayfield',
			    	 fieldLabel:'房号',
			    	 name:'roomName'
				},{
					 xtype:'displayfield',
			    	 fieldLabel:'客户姓名',
			    	 name:'customerName'
				} ]
			},{
				xtype : "panel",
				layout : "hbox",
				items : [ {
					 xtype:'displayfield',
			    	 fieldLabel:'计价面积(㎡)',
			    	 name:'calculateArea'
				},{
					 xtype:'displayfield',
			    	 fieldLabel:'房屋总价(元)',
			    	 name:'discountTotalPrice'
				} ]
			},{
				xtype : "panel",
				layout : "hbox",
				items : [ {
					 xtype:'displayfield',
			    	 fieldLabel:'认筹金(元)',
			    	 name:'payDepositAmount'
				},{
					 xtype:'displayfield',
			    	 fieldLabel:'认筹明细',
			    	 name:'showName',
			    	 value:''
				} ]
			},{
				xtype : "panel",
				layout : "hbox",
				items : [  {
					xtype : 'textarea',
					fieldLabel : '退筹原因',
					width:500,
					name:'remark',
					id:'reason',
					allowBlank:false,
			    	blankText:'不能为空'
				} ]
			},{
				xtype : "panel",
				layout : "hbox",
				items : [ {
					 xtype:'displayfield',
			    	 fieldLabel:'经纪人',
			    	 name:'agentName'
				},
				 {
					 xtype:'displayfield',
			    	 fieldLabel:'申请日期',
			    	 value:str
				}]
			},fileAttachment],
			dockedItems: [{
	            xtype: 'toolbar',
	            dock: 'bottom',
	            ui: 'footer',
	            layout: {
	                pack: 'center'
	            },
	            items: [{
	            	hidden:marketingPayDepositRetreat,
	                minWidth: 80,
	                text: '保存',
	                id:'save_button',
	                handler:function(){
	                	var form = fromPanelInfo.getForm();
	                	if(form.isValid()){
	                		var fileUrlArr =fileAttachment.getFileArrs();
	                		console.log("fileUrlArr = " + fileUrlArr);
	                		var parent={
		                			'payDepositId':payDepositId,
		                			'remark':Ext.getCmp("reason").getValue(),
		                			fileUrlArr:fileUrlArr,
		                			imageType: "6"
		                	};
	                		 Ext.getCmp("save_button").setVisible(false);
	                		Ext.Ajax.request({
		                		url:contextPath+'/customer/payDeposit/submitRetreat',
		                		params:parent,
		                		callback: function (options, success, response) {
		                			 var result = JSON.parse(response.responseText);
		                			 if(result.res=="1"){
		                				
		    							   Ext.MessageBox.alert("系统提示", "提交成功! ", function(but) {  
		    								   //location.href=contextPath+"/customer/payDeposit/toRetreatView?id="+result.obj;
		    				                });  
		    						 }else{
		    							 Ext.getCmp("save_button").setVisible(true);
		    							 Ext.MessageBox.alert("系统提示",result.resMsg); 
		    						 }
		                		}
		                	});
	                		
	                	}
	                }
	            },{
	                minWidth: 80,
	                text: '返回',
	                handler:function(){
	                	//history.go(-1);
	                	self.location=document.referrer;
	                }
	            }]
	        }
	        ]
		   
	   });
	   
	   fromPanelInfo.getForm().load({
			url:contextPath+'/customer/payDeposit/loadRetreat',
			params:{'payDepositId':payDepositId},
			success:function(form, action){
				var obj = action.result.data;
				 var result=Ext.JSON.decode(obj);
				fromPanelInfo.getForm().setValues(result);
				var jumpUrl=contextPath+'/customer/payDeposit/toView?id='+result.id+"&processFlag=processHistoryShow&returnUrl=,customer,payDeposit,toRetreat(payDepositId)"+payDepositId;
				var showValue='<a href="'+jumpUrl+'" target="_blank">点击查看认筹明细</a>';
				fromPanelInfo.getForm().findField("showName").setValue(showValue);
			},   
			failure: function(form, action) {
		        Ext.Msg.alert("加载失败", action.result.errorMessage);
		    }

		});
});